package com.lorenzogao.festec

import android.util.Log
import android.widget.Toast
import com.lorenzogao.latte_core.delegates.LatteDelegate
import com.lorenzogao.latte_core.net.RestClient
import com.lorenzogao.latte_core.net.callback.IError
import com.lorenzogao.latte_core.net.callback.IFailure
import com.lorenzogao.latte_core.net.callback.ISuccess

/**
 *  create by LorenzoGao
 *  email: 2508719070@qq.com
 *  TIME: 2020-01-08 11:18
 *  description:
 */

class ExampleDelegate : LatteDelegate() {


    override fun initView() {

        testRestClient()

    }

    override fun setLayout(): Any {
        return R.layout.delegate_example
    }


    private fun testRestClient() {

        RestClient.builder()

            .loader(activity!!)
            .url("https://wanandroid.com/wxarticle/chapters/json")
            .success(object : ISuccess {
                override fun onSuccess(response: String) {
                    Log.e("TAG", response)
                }
            })
            .error(object : IError {
                override fun onError(code: Int, msg: String) {
                    Log.e("TAG", "onError")
                }

            })
            .failure(object : IFailure {
                override fun onFailure() {
                }

            }).builder().get()

    }

}